import {requestDel, requestGet, requestPatch, requestPost} from './request'


export async function getChannel(id) {
  return await requestGet(`/channel/${id}`)
}

export async function getChannelDetail(id) {
  return await requestGet(`/channel/${id}/retrieve_detail/`)
}

export async function getChannelList({page = 1, pageSize = 10, channel_type}) {
  return await requestGet('/channel/', {page, pageSize, channel_type})
}

export async function createChannelWithNodes(channel) {
  return await requestPost('/channel/create_with_nodes/', channel)
}

export async function getChannelListDetail({page = 1, page_size = 1000, type = "video"}) {
  return await requestGet('/channel/list_detail/', {
    channel_type: type
  })
}

export async function deleteChannel(id) {
  return await requestDel(`/channel/${id}/`)
}

export async function updateChannel(channel) {
  return await requestPatch(`/channel/${channel.id}/`, channel)
}


export async function getChannelAlarmList(page = 1, page_size = 1000, channel_type = 'video') {
  return await requestGet('/channel/levels_alarm_count/', {
    page,
    page_size,
    channel_type
  })
}


